package com.qf.team2.netdisc.common.pojo.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Objects;

/**
 * 用户实体类
 *
 * @author Simon_Wong
 * @date 2021/05/20
 * @since 2021/5/20 9:06
 */
@ApiModel("用户实体")
public class User {

    @ApiModelProperty("用户id")
    private Integer id;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("电子邮箱")
    private String email;
    @ApiModelProperty(value = "角色", notes = "只能用枚举类CharacterCode来设置")
    private Integer character;

    @ApiModelProperty("用户对应的根目录id")
    private Integer rootId;

    @ApiModelProperty("用户当前占用的容量空间")
    private Integer capacity;

    @ApiModelProperty("是否删除")
    private Integer isDelete;

    public User() {
    }

    public User(Integer id, String username, String password, String email, Integer character, Integer rootId,
                Integer capacity, Integer isDelete) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.email = email;
        this.character = character;
        this.rootId = rootId;
        this.capacity = capacity;
        this.isDelete = isDelete;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getCharacter() {
        return character;
    }

    public void setCharacter(Integer character) {
        this.character = character;
    }

    public Integer getRootId() {
        return rootId;
    }

    public void setRootId(Integer rootId) {
        this.rootId = rootId;
    }

    public Integer getCapacity() {
        return capacity;
    }

    public void setCapacity(Integer capacity) {
        this.capacity = capacity;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return id.equals(user.id) && username.equals(user.username) && password.equals(user.password) && email
                .equals(user.email) && character.equals(user.character) && rootId.equals(user.rootId) && capacity
                .equals(user.capacity) && isDelete.equals(user.isDelete);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, password, email, character, rootId, capacity, isDelete);
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", character=" + character +
                ", rootId=" + rootId +
                ", capacity=" + capacity +
                ", isDelete=" + isDelete +
                '}';
    }

    /**
     * 角色码
     *
     * @author Administrator
     * @date 2021/05/20
     */
    public enum CharacterCode {
        /**
         * 管理员
         */
        ADMIN(0),
        /**
         * 普通用户
         */
        COMMON_USER(1),
        /**
         * vip用户
         */
        VIP_USER(2);

        private final int VALUE;

        CharacterCode(int value) {
            this.VALUE = value;
        }

        public int getValue() {
            return VALUE;
        }
    }
}
